<script type="text/javascript"
     src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<head>
    <link rel="stylesheet" href="stylesheet_TMATS.css">
</head>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<title>
    T-MATS: Help for 1D Trans Cond Model(CN) Library Block
</title>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<body>
    <h1>
      T-MATS: 1D Trans Cond Model(CN) Library Block
    </h1>
<hr>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="purpose">
        Purpose
</div>

<p>
    This block is used to model the transient conduction of a plate with
    fluid or additional plates on either side via the finite difference
    method (Crank-Nicolson).
</p>
<p>
    <em>Note:</em> This block has become obsolete and will not be supported
    in future releases. For a more versatile option, see the 1-D Trans
    Conduction Model - Variable Props + Generic BCs (documentation
    <a href="HeatXfer_TMATS_1DTCondVarPropGenBC.html">here</a>).
</p>

<br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="background">
        Background
</div>

<p>
    To compute the output temperatures, this block divides a general-use
    material into three sections: the plate (Region B), fluid/solid on one side
    of the plate (Region A), and fluid/solid on the other side of the plate
    (Region C). The finite difference method (Crank-Nicolson) is then used
    to determine the effects of the heat transfer through region B via a 1-D heat transfer.
</p>
<p>
    Region A can be defined as a fluid or a solid material at the inner
    boundary. If it is a fluid, the variable <i>TinnerNext</i> is set to
    be constant. If it is defined as a solid, the thermodynamic properties
    need to be defined manually and <i>TinnerNext</i> needs to be connected
    to the adjacent node of another 1-D Trans Conduction Model (CN) block.
    The thermodynamic properties for Region A are accessed by double clicking
    the block and adjusting the values in the "Inner Material" tab.
</p>
<p>
    Region B is the plate, and its material properties are defined in the
    General Tab (accessed by double clicking the block).
</p>
<p>
    Region C is defined similarly to A, however it is considered the outer
    material. Just like Region A, if Region C is defined to be solid, the
    thermodynamic properties need to be set manually by double clicking the
    block and adjusting the values in the "Outer Material" tab.
</p>
<p>
    Export values are calculated based on a single time step. If additional
    dynamic behavior is required, a Simulink Memory block may be used to update
    the temperature initial conditions. When using this block, an external
    solver should be used to determine the values of <i>TinnerNext</i> and
    <i>TouterNext</i>. Units must be specified consistantly throughout this
    block (i.e. If temperature is input as Celsius, all temperature units
    must Celsius).
</p>
<p>
	This block subdivides Region B into nodes and solving the heat equation for each (assuming negligible radiation).
</p>
<p>
	The heat equation is defined as:
	$$ \frac{\rho*C_p}{k}*\frac{\partial T}{\partial t}=\frac{\partial ^2T}{\partial x^2} $$
	For each node this may be represented by an energy balance.
	$$ \dot{Q}_{node} = \sum\dot{Q}_{conduction} + \sum\dot{Q}_{convection}$$
	with components defined as:
	$$ \dot{Q}_{node} = \frac{\rho*C_p}{\partial t}(T_n^{p+1} - T_n^{p}) $$
	$$ \dot{Q}_{conduction} = \frac{kA}{2\partial x}((T_{n\pm 1}^{p}-T_n^{p})+(T_{n\pm 1}^{p+1}-T_n^{p+1})) $$
	$$ \dot{Q}_{convection} = \frac{hA}{2}((T_{n\mp 1}^{p}-T_n^{p})+(T_{n\mp 1}^{p+1}-T_n^{p+1})) $$
	where <i>n</i> denote the node number and <i>p</i> denote current time step (<i>p + 1</i> is the next time step).
</p>
<p>
    To determine the output values, this block generalizes the equations by calculating the thermal
    diffusivity constant, Biot number, and Fourier number for each material.
    For Region A and Region C, these constants are determined by the following
    equations, respectively.

    $$ \alpha = \frac{k}{\rho*Cp}$$
    $$ Bi = \frac{h*dx}{k}$$
    $$ Fo = \frac{dt*\alpha}{dx^2}$$

    Additionally, node width <i>dx</i> for Region B must be calculated; the equation below
    is used to determine this parameter (it should be noted that transition nodes are on the surface of the material if the abutted material is a fluid. If it is a solid then the node is central.):

    $$ dx_B = \frac{X}{N-\left(1 - \frac{A}{2}-\frac{C}{2}\right)}$$

    in which <i>X</i> is the plate width, <i>N</i> is the number of nodes,
    and <i>A</i> and <i>C</i> are each a 0 or 1 depending on if the
    corresponding region is specified to be a fluid or a solid, respectively.
</p>
<p>
    Once these parameters are calculated for each region, the thermal diffusivity
    constant and Fourier number for the transition regions (B-C, B-A) are
    determined. For Region BC, the following equations are used:

    $$\alpha_{BC} = \frac{\left(\frac{k_B*dx_B + k_C*dx_C}{dx_B + dx_C}\right)}{\rho*Cp}$$
    $$Fo_{BC} = \frac{dt* \alpha_{BC}}{dx_B * \left(\frac{dx_C+dx_B}{2}\right)}$$

    For Region BA, the above equations are used with the corresponding values
    for Region A in place of the values for Region C.
</p>
<p>
    With the thermodynamic parameters specified for all regions of the material,
    a MATLAB script is used to determine the node temperatures by using
    the Crank-Nicolson finite different method. This method is based on the
    trapezoidal rule and combines the forward and backward Euler methods to solve the heat equation described
    in the generalized energy equations above. The final implementation is shown below.
    In this solution the current tempertaure is calculated using all current and future node values.
    A solver is then used to update the future nodal temperatures until the calculated nodal temperatures match the actual current nodal temperatures.
</p>
<p>
    At the boundary for Region A, the following equations are used to determine
    the temperature, assuming Region A is solid.

    $$T_{forward} = -(Fo_B*T_{m+1} + Fo_{BA}*T_{inner}) + (Fo_B + Fo_{BA})*T_m$$
    $$T_{back} = -(Fo_B*Tnext_{m+1} +Fo_{BA}*Tnext_{inner}) + (Fo_B+Fo_{BA})*Tnext_m$$
    $$Tcalc = 0.5*(T_{forward}+T_{backward}) + Tnext_m$$

    In the equations above, and the ones that will follow, <i>m</i> represents
    the location of the node. If Region A is fluid,
    the following equations are used instead.

    $$T_{forward} = (2*Fo_B+2*Bi_B*Fo_B)*T_{m} - 2*Fo_B(T_{m+1} +Bi_B * T_{inner})$$
    $$T_{back} = (2*Fo_B+2*Bi_B*Fo_B)*Tnext_{m} - 2*Fo_B*(Tnext_{m+1} + Bi_B*Tnext_{inner})$$
    $$Tcalc = 0.5*(T_{forward}+T_{backward}) + Tnext_m$$

    Similarly, the temperature at the boundary of Region C is determined by the
    following set of equations, assuming that Region C is solid:

    $$T_{forward} = -(Fo_B*T_{m-1} + Fo_{BC}*T_{outer}) + (Fo_B + Fo_{BC})*T_m$$
    $$T_{back} = -(Fo_B*Tnext_{m-1} +Fo_{BC}*Tnext_{outer}) + (Fo_B+Fo_{BC})*Tnext_m$$
    $$Tcalc = 0.5*(T_{forward}+T_{backward}) + Tnext_m$$

    If Region C is fluid, the following equations are used instead:

    $$T_{forward} = (2*Fo_B+2*Bi_B*Fo_B)*T_{m} - 2*Fo_B(T_{m-1} +Bi_B * T_{outer})$$
    $$T_{back} = (2*Fo_B+2*Bi_B*Fo_B)*Tnext_{m} - 2*Fo_B*(Tnext_{m-1} + Bi_B*Tnext_{outer})$$
    $$Tcalc = 0.5*(T_{forward}+T_{backward}) + Tnext_m$$

    To determine the temperature of the internal nodes, the following equations
    are used:

    $$T_{forward} = 2*Fo_B*T_m - Fo_B *(T_{m+1} + T_{m-1})$$
    $$T_{back} = 2*Fo_B*Tnext_m - F0_B*(Tnext_{m+1} + Tnext_{m-1})$$
    $$Tcalc = 0.5*(T_{forward} +T_{back}) +Tnext_m$$

    The error between the calculated value and the actual value is determined
    by the following equation:

    $$Terr = \frac{Tcalc - ToVec}{ToVec}$$

    In which <i>Tcalc</i> is the vector of the current, calculated values for
    the temperature across the material and <i>ToVec</i> is the current
    temperature state input of the system. Once the values in <i>Terr</i> approach zero (based on local solver option settings) <i>TNext</i> values are the new temperature states of the system.
</p>
<p>
    The final parameter determined by this block is the average temperature,
    which is determined by the following equation:

    $$Tavg = \frac{\sum(TNext * Nw)}{\sum Nw}$$

    In the above equation, <i>Nw</i> is the vector containing the <i>dx</i>
    values.
</p>
<br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="instructions">
        Instructions
</div>

<p>
    To use this block:
    <ul>
        <li> Connect the inputs to the corresponding places on the block.
        <li> Connect the outputs to the next blocks in the simulation.
        <li> Double click the block and...
        <ul>
            <li>Specify the properties of Region B (the plate) by editing
            the values in the General tab.
            <li>If Region A is solid, check the box under the Inner Material
            tab and specify the properties of Region A.
            <li>If Region A is fluid, ensure that the box under the Inner Material
            tab is not checked.
            <li>If Region C is solid, check the box under the Outer Material
            tab and specify the properties of Region C.
            <li>If Region C is fluid, ensure that the box under the Outer Material
            tab is not checked.
        </ul>
        <li> Use an external solver to determine the Next temperature values.
        <li> Ensure that temperature units are consistent throughout this block.
    </ul>
</p>


<br><hr><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="inputs">
      1D Trans Cond Model(CN) Inputs
</div>

<table>
    <tr><th> Input </th><th>Description</th></tr>
    <tr><td>Tinner</td><td>Initial temperature adjacent to the inner most node</td></tr>
    <tr><td>TinnerNext</td><td>Next temperature adjacent to the inner most node</td></tr>
    <tr><td>Touter</td><td>Initial temperature adjacent to the outer most node</td></tr>
    <tr><td>TouterNext</td><td>Next temperature adjacent to the outer most node</td></tr>
    <tr><td>ToVec</td><td>Initial temperature at each node (mx1)</td></tr>
    <tr><td>TNext</td><td>Temperature at each node for next time step (mx1)</td></tr>
</table>

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="outputs">
       1D Trans Cond Model(CN) Outputs
</div>

<table>
    <tr><th> Output </th><th> Description </th></tr>
    <tr><td>Tavg</td><td>Final Average Temperature within the Plate</td></tr>
    <tr><td>TfVec</td><td>Final Temperature at each Node (mx1)</td></tr>
    <tr><td>Xdist</td><td>Placement of each Node (mx1)</td></tr>
    <tr><td>Terr</td><td>Difference between initial and calculated intial temperatures (mx1)</td></tr>
</table>

<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

<div class="maskvars">
        1D Trans Cond Model(CN) Mask Variables
</div>

<table>
    <tr><th> Mask Variable </th><th> Description </th></tr>
    <tr><td>dt_M</td><td>Time Step</td></tr>
    <tr><td>w_M</td><td>Plate total Width</td></tr>
    <tr><td>Node_M</td><td>Number of Nodes in material B</td></tr>
    <tr><td>hB_M</td><td>Material Convection Heat Transfer Coefficient (h)</td></tr>
    <tr><td>kB_M</td><td>Material Thermal Conductivity (k)</td></tr>
    <tr><td>rhoB_M</td><td>Material Density (rho)</td></tr>
    <tr><td>cB_M</td><td>Material Specific Heat (Cp)</td></tr>
    <tr><td>TypeA_M</td><td>Material type adjacent to side A (inner), unset - fluid, set - solid</td></tr>
    <tr><td>wNodeA_M</td><td>width of side A material node</td></tr>
    <tr><td>hA_M</td><td>Material A Convection Heat Transfer Coefficient (h)</td></tr>
    <tr><td>kA_M</td><td>Material A Thermal Conductivity (k)</td></tr>
    <tr><td>rhoA_M</td><td>Material A Density (rho)</td></tr>
    <tr><td>cA_M</td><td>Material A Specific Heat (Cp)</td></tr>
    <tr><td>TypeC_M</td><td>Material type adjacent to side C (inner), unset - fluid, set - solid</td></tr>
    <tr><td>wNodeC_M</td><td>width of side A material node</td></tr>
    <tr><td>hC_M</td><td>Material A Convection Heat Transfer Coefficient (h)</td></tr>
    <tr><td>kC_M</td><td>Material A Thermal Conductivity (k)</td></tr>
    <tr><td>rhoC_M</td><td>Material A Density (rho)</td></tr>
    <tr><td>cC_M</td><td>Material A Specific Heat (Cp)</td></tr>
</table>


<br><br>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
</body>